package com.yyjj.hangqing.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.aries.ui.view.title.TitleBarView;
import com.yyjj.hangqing.R;
import com.yyjj.hangqing.adapter.viewpager.VPTitleAdapter;
import com.zhengsr.viewpagerlib.indicator.TabIndicator;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import tech.com.commoncore.base.BaseTitleFragment;
import tech.com.commoncore.basecomponent.ServiceFactory;
import tech.com.commoncore.utils.OnNoDoubleClickListener;

/**
 * Anthor:NiceWind
 * Time:2019/3/25
 * Desc:The ladder is real, only the climb is all.
 */
public class HQFragment extends BaseTitleFragment {

    private com.zhengsr.viewpagerlib.indicator.TabIndicator mLineIndicator;
    private ViewPager mViewpager;

    public static final String[] TYPES = {"bituan", "bitmex", "huobipro", "cointiger", "okex"};
    List<Fragment> fragmentList = new ArrayList<>();

    public static HQFragment newInstance( Bundle args) {
        HQFragment fragment = new HQFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void setTitleBar(TitleBarView titleBar) {
        titleBar.setTitleMainText(getResources().getString(R.string.hq_hq_app_title));
    }

    @Override
    public int getContentLayout() {
        return R.layout.hq_fragment;
    }

    @Override
    public void initView(Bundle savedInstanceState) {
        mLineIndicator = (TabIndicator) mContentView.findViewById(R.id.line_indicator);
        mViewpager = (ViewPager) mContentView.findViewById(R.id.viewpager);

        mLineIndicator.setViewPagerSwitchSpeed(mViewpager, 600);
        mLineIndicator.setTabData(mViewpager, Arrays.asList(TYPES), new TabIndicator.TabClickListener() {
            @Override
            public void onClick(int position) {
                //顶部点击的方法公布出来
                mViewpager.setCurrentItem(position);
            }
        });
//        fragmentList.add(ServiceFactory.getInstance().getBiService().getCacheCoinFragment());
        fragmentList.add(CoinListFragment.newInstance("bituan"));
        fragmentList.add(CoinListFragment.newInstance("bitmex"));
        fragmentList.add(CoinListFragment.newInstance("huobipro"));
        fragmentList.add(CoinListFragment.newInstance("cointiger"));
        fragmentList.add(CoinListFragment.newInstance("okex"));
        mViewpager.setOffscreenPageLimit(6);
        mViewpager.setAdapter(new VPTitleAdapter(getChildFragmentManager(), fragmentList, Arrays.asList(TYPES)));

    }
}
